package com.sws.yygh.common.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @program: Appointment-hospital-registration-system
 * @description: MybatisPlus配置类
 * @author: sws
 * @create: 2022-06-28 16:19
 */
@EnableTransactionManagement  //事务处理
@Configuration
@MapperScan("com.sws.yygh.*.mapper")
public class MybatisPlusConfig {

    /**
     * 分页插件bean
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor (){
        return new PaginationInterceptor();
    }

    /**
     * 乐观锁配置
     *
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }
}
